
package x.trident.core.mongodb.service.impl;

import x.trident.core.mongodb.api.MongodbApi;
import x.trident.core.mongodb.entity.TridentMapEntity;
import x.trident.core.mongodb.mapper.TridentMapRepository;
import x.trident.core.mongodb.service.TridentMapService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * Mongodb 数据存储实现类
 *
 * @author huziyang
 * @date 2021/03/20 16:24
 */
@Service
public class TridentMapServiceImpl implements TridentMapService, MongodbApi<TridentMapEntity, String> {

    @Resource
    private TridentMapRepository TridentMapRepository;

    @Override
    public TridentMapEntity insert(TridentMapEntity TridentMapEntity) {
        return TridentMapRepository.insert(TridentMapEntity);
    }

    @Override
    public TridentMapEntity update(TridentMapEntity TridentMapEntity) {
        return TridentMapRepository.save(TridentMapEntity);
    }

    @Override
    public void deleteById(String id) {
        TridentMapRepository.deleteById(id);
    }

    @Override
    public Optional<TridentMapEntity> findById(String id) {
        return TridentMapRepository.findById(id);
    }

    @Override
    public List<TridentMapEntity> findAll() {
        return TridentMapRepository.findAll();
    }

}
